<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let promise1 = new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve(5)
            }, 2000)
        })

        let promise2 = new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve(6)
            }, 1000)
        })

        // 可以接收多个promise作为参数 当所有的promise都执行结束后会返回结果
        // Promise.all([promise1, promise2]).then((res) => {
        //     let num = res[0] + res[1]
        //     console.log(num);
        // });
        // 可以接收多个promise作为参数 当其中一个promise率先发生变化后就会执行的逻辑
        // Promise.race([promise1, promise2]).then(res => {
        //     console.log(res);
        // })
    </script>
</body>

</html>